<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%
/*"http://localhost:82/AppCooperativaDWP/FacArticulos.jsp?jdbc="+jdbc+
	    				"&user="+usr+
	    				"&pass="+pass+
	    				"&barras="+codigoB.getString();

ejemplo:
	http://localhost:82/AppCooperativaDWP/Articulo.jsp?
			jdbc=jdbc:sybase:Tds:132.147.160.40:5000/super9_bak
			&user=dba
			&pass=sql
			&barras=7792900006857
	*/

String param = "";
String jdbc, user, pass;
jdbc = request.getParameter("jdbc");
user = request.getParameter("user");
pass = request.getParameter("pass");

System.out.println("jdbc: "+jdbc);
System.out.println("user: "+user);
System.out.println("pass: "+pass);


if (request.getParameter("barras") != null && request.getParameter("barras") != ""){
	param = request.getParameter("barras"); //nombre del parametro.
}else{
	param = "$$$";
}

System.out.println("barras: "+param);

//   int iparam = Integer.parseInt(param);
try{
	Class.forName("com.sybase.jdbc3.jdbc.SybDriver").newInstance();
	
	Connection cn = DriverManager.getConnection(jdbc, user, pass);
	PreparedStatement cmd = cn.prepareStatement("select * from fac_articulos where art_barras = ?;");
	cmd.setString(1, param);
	ResultSet rs = cmd.executeQuery();
	
//				1			2			3			4				5				6			7				8
//articulo: art_codigo; art_barras; art_descri; art_existencia; art_ult_comp; art_ult_venta; art_ult_pedido; padron_codigo.

	while (rs.next()){ //el nombre pasado, deben ser las columnas de la tablas en la base.
		out.print(rs.getString("art_codigo")+"|"+ 
					rs.getString("art_barras")+"|"+ 
 					rs.getString("art_descri")+"|"+
					rs.getString("art_existencia")+"|"+
					rs.getString("art_ult_comp")+"|"+
					rs.getString("art_ult_venta")+"|"+
					rs.getString("art_ult_pedido")+"|"+
					rs.getString("padron_codigo")
					); 
	}	
	rs.close();
	cmd.close();
	cn.close();
}catch (Exception e){
	out.print(e.getMessage());
}
%>